package com.ayoka.mvp;

import android.app.Activity;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.ayoka.R;
import com.ayoka.base.BasePresenter;
import com.ayoka.base.IBaseView;
import com.ayoka.mvp.MeditationMVP.MeditationModel.MeditationBean;
import com.ayoka.utils.MediaManager;
import com.jcp.baselibrary.dialog.DialogHelper;

import java.io.Serializable;

/**
 * Created by gabriel on 2017/3/5.
 */

public interface MeditationMVP {

    interface MeditationModel {

        class MeditationBean implements Serializable {
            public int ID;
            public int CourseID;
            public int TaskID;
            public int ItemID;
            public int IsCompleted;
            public int IsFavorited;
            public String CreateDate;
        }

    }

    interface IMeditationView extends IBaseView {

        void configMeditationDetailData(MeditationBean meditationBean);
    }

    class MeditationPresenter extends BasePresenter<IMeditationView> {

        public void getMeditationDetailData(int meditationId, int taskId) {
            mViewRef.get().configMeditationDetailData(new MeditationBean());
        }

        public void AddMeditationRecord(int courseID, int id, int taskId) {
        }

        public void showConfirmQuitMeditationDialog(final Activity activity) {
            View confirmQuitView = LayoutInflater.from(activity).inflate(R.layout.dialog_confirm_tow_button, null);
            final AlertDialog dialog = DialogHelper.getDialog(activity).show();
            dialog.setContentView(confirmQuitView);
            TextView tvTitle = confirmQuitView.findViewById(R.id.tv_dialog_title);
            tvTitle.setText(R.string.point_out);
            TextView tvMessage = confirmQuitView.findViewById(R.id.tv_dialog_message);
            tvMessage.setText(R.string.meditation_not_yet_completed);
            confirmQuitView.findViewById(R.id.btn_positive).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dialog.dismiss();
                    activity.finish();
                }
            });
            confirmQuitView.findViewById(R.id.btn_negative).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dialog.dismiss();
                    MediaManager.getInstance().resume();
                }
            });
            MediaManager.getInstance().pause();
        }

        public void showStartMeditationDialog(final Activity activity) {
            View confirmQuitView = LayoutInflater.from(activity).inflate(R.layout.dialog_confirm_one_button, null);
            final AlertDialog dialog = DialogHelper.getDialog(activity).show();
            dialog.setContentView(confirmQuitView);
            TextView tvTitle = confirmQuitView.findViewById(R.id.tv_dialog_title);
            tvTitle.setText(R.string.point_out);
            TextView tvMessage = confirmQuitView.findViewById(R.id.tv_dialog_message);
            tvMessage.setText(R.string.meditation_need_quite_place);
            Button btnConfirm = confirmQuitView.findViewById(R.id.btn_confirm);
            btnConfirm.setText(R.string.start_training);
            btnConfirm.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dialog.dismiss();
                }
            });
        }
    }

}
